﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Manage/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<QianBuo.Lottery.Web.Areas.Manage.Models.User.DeleteModel>" %>
<%@ Import Namespace="Code.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	删除用户
    <% TempData["DeleteType"]=Model.DeleteType; %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<fieldset>
    <% if (Model.DeleteType == 2)
       { %>
    <legend>删除无账变用户</legend>
    <%Html.BeginForm(new { id="serchform"},null); %>
    <%=Html.HiddenFor(p=>p.DeleteType) %>
    <div align="center">
    <table class="table" width='50%'>
        <tr><th colspan='2' align="left">搜索条件</th></tr>
        <tr>
            <td><%=Html.LabelFor(p => p.StartTime)%>:</td>
            <td><%=Html.TextBoxFor(p => p.StartTime, new { onClick = "WdatePicker()"})%>
            <%=Html.ValidationMessageFor(p=>p.StartTime) %>
            </td>
        </tr>
        <tr>
            <td><%=Html.LabelFor(p => p.MinMoney)%></td>
            <td><%=Html.TextBoxFor(p => p.MinMoney)%><%=Html.ValidationMessageFor(p=>p.MinMoney) %></td>
        </tr>
        <tr>
            <td colspan='2'><input type="submit" name="Search" value="查找" /></td>
        </tr>
    </table>
    </div>
    <%}
       else
       { %>
    <legend>删除指定用户</legend>
    <%Html.BeginForm(new { id = "serchform" }, null); %>
    <%=Html.HiddenFor(p=>p.DeleteType) %>
    <div align="center">
    <table class="table" width='50%'>
        <tr><th colspan='2' align="left">搜索条件</th></tr>
        <tr>
            <td><%=Html.LabelFor(p => p.UserName)%>:</td>
            <td><%=Html.TextBoxFor(p => p.UserName, new { validate = "{required:true,messages:{required:'*'}}" })%></td>
        </tr>
        <tr>
            <td colspan='2'><input type="submit" name='Search' value="查找" /></td>
        </tr>
    </table>
    </div>
    <%}
        Html.EndForm(); %>
    <div>
    <% Html.BeginForm(); %>
    <table class="table" width="100%">
        <tr>
            <th>
                全选<input id='ckb_All' type="checkbox" onclick="ckb_Click(this.checked,0)" />
                反选<input id='ckb_Other' type="checkbox" onclick="ckb_Click(this.checked,1)" />
            </th>
            <th>用户名</th>
            <th>总金额</th>
            <th>类型</th>
            <th>注册时间</th>
        </tr>
        <%  if (Model.SeachResult != null)
            {
                foreach (var user in Model.SeachResult)
                {
                  %>
                    <tr>
                        <td><input type="checkbox" name='ids' value='<%=user.Uid %>' /></td>
                        <td><%=user.LoginName%></td>
                        <td><%=user.Money%></td>
                        <td><%=((UserType)user.UserTye).GetName()%></td>
                        <td><%=user.RegistTime.ToString("yyy-MM-dd HH:mm:ss")%></td>
                    </tr>  
                  <%
            }
            %>
    </table>
    <div align="left">
        <table class="table" width="50%">
            <% if (Model.SeachResult != null && Model.SeachResult.Count > 0){ %>
                <% if (!(Model.DeleteType == 1 && Model.SeachResult.First().UserTye == (short)UserType.Member))
                   { %>
                <tr>
                    <th colspan='2'>请指定要删除的用户的下级的新上级代理</th>
                </tr>
                <tr>
                    <td>代理:<%=Model.CommCommand == null ? Html.Label("默认") : Html.DropDownList("id", Model.CommCommand.Select(s => new SelectListItem { Text = s.LoginName, Value = s.Uid.ToString() }), "默认")%></td>
                    <td>注：'默认'为转移到要删除的用户的直接上级代理下</td>
                </tr>
                <%}
               } %>
            <tr>
                <td></td>
                <td>
                    <input type="submit" name="Delete" value="删除选中用户" onclick="return btn_DeleteUser_Click()"/>
                </td>
            </tr>
        </table>
    </div>
    <%=Html.HiddenFor(p => p.DeleteType)%>
    <% }
            else             
            { 
                %></table><%
            }
        
        Html.EndForm(); %>
    </div>
</fieldset>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="StyleAndScript" runat="server">
    <script src='<%=Url.Content("~/Scripts/jquery.metadata.js") %>' type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#serchform").validate();
    });
    function ckb_Click(checked,type) {
        var ckbs = document.getElementsByName('ids');
        if (type == 1) {
            document.getElementsByName('ckb_All').checked = false;
        }
        else {
            document.getElementsByName('ckb_Other').checked = false;
        }
        for (var i = 0; i < ckbs.length; i++) {
            if (type == 1) {
                var flag = ckbs[i].checked;
                ckbs[i].checked = !flag;
            }
            else {
                ckbs[i].checked = checked;
            }
        }
    }
    function btn_DeleteUser_Click() {
        var ckbs = document.getElementsByName('ids');
        for (var i = 0; i < ckbs.length; i++) {
            if (ckbs[i].checked) {
                return confirm('删除用户时，和用户有关的所有记录都将会删除。您确定要删除所选中的用户?');
            }
        }
        alert('您还没有选中用户');
        return false;
    }
</script>
</asp:Content>
